package user

import (
	"common/mildware"
	"common/router"
	"github.com/gin-gonic/gin"
	"video/pkg/dao/mysql"
	"video/pkg/dao/redis"
)

type URouter struct {
}
type UHandler struct {
	M mysql.Mysql
	R redis.Redis
}

func init() {
	router.AddRouter(new(URouter))
}
func NewUserHandler() UHandler {
	return UHandler{
		M: mysql.NewMysql(),
		R: redis.NewRedis(),
	}
}
func (URouter) Router(e *gin.Engine) {
	handler := NewUserHandler()
	user := e.Group("/v1/user")
	user.POST("/login", handler.Login)
	user.POST("/register", handler.Register)
	user.Use(mildware.JWTAuthMiddleware())
	user.POST("/update/img", handler.UpdateUserImg)
	user.POST("/update/base", handler.UpdateUserBaseInfo)
	user.POST("/update/password", handler.UpdateUserPasswordInfo)
	user.POST("/userInfo", handler.GetUserInfo)
}
